<extend name="Member:base" />
<block name="title"><title>心心向善-账户信息</title></block>
		<!-- 头部结束-->
<block name="body">

			<!--<主要区块>-->

			<div class="right-layout">
				<div class="wrap">
					<div class="tabmenu">
						<ul class="tab pngFix">
							<li class="active">
								<a href="shdz.html">地址列表</a>
							</li>
						</ul>
						<a href="javascript:void(0)" class="ncm-btn ncm-btn-orange" onclick="block('#fwin_my_address_edit')">新增地址</a>
					</div>
					<div class="alert alert-success">
						<h4>操作提示：</h4>
						<ul>
							<li>最多可保存20个有效地址</li>
						</ul>
					</div>
					<table class="ncm-default-table">
						<thead>
							<tr>
								<th class="w80">收货人</th>
								<th class="w150">所在地区</th>
								<th class="tl">街道地址</th>
								<th class="w120">电话/手机</th>
								<th class="w150"></th>
								<th class="w110">操作</th>
							</tr>
						
						</thead>
						<tbody>
						<foreach name='list' item='v'>
							<tr class="bd-line">
								<td>{$v.realname}</td>
								<td>{$v.province} {$v.city} {$v.area}</td>
								<td class="tl"><em class="delivery"></em>{$v.address}</td>
								<td>
									<p>{$v.tel_phone}</p>
									<p>{$v.mob_phone}</p>
								</td>
								<td></td>
								<td class="ncm-table-handle">
									<span>
					                    <a href="/member/xgdz.html?id={$v.id}" class="btn-blue">
							          		<p>编辑</p>
							          	</a>
				                    </span>
									<span>
				                    	<a onClick="javascript:if(!confirm('确定删除此地址？'))  return  false; " href="/member/deldz.html?id={$v.id}" class="btn-red">
								          	<p>删除</p>
								      	</a>
				                    </span>
								</td>
							</tr>
						</foreach>
						</tbody>
					</table>
				</div>
			</div>
			<div id="fwin_my_address_edit" class="dialog_wrapper ui-draggable" style="z-index: 1100; position: absolute; width: 550px; left: 436.5px; top: 300px; display: none;">
				<div class="dialog_body" style="position: relative;">
					<div class="dialog_content" style="margin: 0px; padding: 0px;">
						<div class="eject_con">
							<div class="adds">
								<div id="warning" style="display: none;"></div>
								<form method="post" action="xzdz" id="address_form" target="_parent">
									<input type="hidden" name="form_submit" value="ok">
									<input type="hidden" name="id" value="">
									<dl>
										<dt><i class="required">*</i>收货人：</dt>
										<dd>
											<input type="text" class="text w100" name="true_name" value="">
											<p class="hint">请填写真实姓名</p>
										</dd>
									</dl>
									<dl>
										<dt><i class="required">*</i>所在地区：</dt>
										<dd>
											<div id="region">

										<select name="province" id="code">
											<option >请选择省份</option>
										
										<volist name="code" id="vo">						
											  <option value ="{$vo.area_name}" data-id="{$vo.area_id}">{$vo.area_name}</option>						
										</volist>
										</select>

										<select id="cobb" name="city">
											<option >市</option>	

										<volist name="citylist" id="vo">						
											  <option value ="{$vo.area_name}" data-id="{$vo.area_id}">{$vo.area_name}</option>						
										</volist>
										</select>
										
										<select id="cocc" name="area">
											<option >区、县</option>

										<volist name="cityson" id="vo">						
											  <option value ="{$vo.area_name}" data-id="{$vo.area_id}">{$vo.area_name}</option>						
										</volist>					
										</select>

											</div>
										</dd>
									</dl>
									<dl>
										<dt><i class="required">*</i>街道地址：</dt>
										<dd>
											<input class="text w300" type="text" name="address" value="">
											<p class="hint">不必重复填写地区</p>
										</dd>
									</dl>
									<dl>
										<dt><i class="required">*</i>电话号码：</dt>
										<dd>
											<input type="text" class="text w200" name="tel_phone" value="">
											<p class="hint">区号 - 电话号码 - 分机</p>
										</dd>
									</dl>
									<dl>
										<dt><i class="required">*</i>手机号码：</dt>
										<dd>
											<input type="text" class="text w200" name="mob_phone" value="">
										</dd>
									</dl>
									<dl>
										<dt><em class="pngFix"></em>设为默认地址：</dt>
										<dd>
											<input type="checkbox" class="checkbox vm mr5" name="is_default" id="is_default" value="1">
											<label for="is_default">设置为默认收货地址</label>
										</dd>
									</dl>
									<div class="bottom">
										<label class="submit-border">
												<input type="hidden" name="addresshash" id="addresshash" value="">
										  <input type="submit" class="submit" value="新增地址">
										</label>
										<a class="ncm-btn ml5" href="javascript:;" onclick="clos('#fwin_my_address_edit')">取消</a>
									</div>
								</form>
							</div>
						</div>
						<script>
							function clos(id){
								$(id).hide()
							}
							function block(id){
								$(id).show()
							}
						</script>
						<!--</主要区块>-->
						<div class="clear"></div>
					</div>
				</div>
			</div>

</div>

	<script>
        $('#code').change(function(){
			var name = $(this).val();
            var code = $(this).find("option[value='"+name+"']").attr("data-id");
			var url = '{:U("/shop/code_chage")}';
			//alert(code);
			if (code) {			
				$.ajax({
					url:url,
					data:{id:code},
					type:'post',
					//dataType:'json',
					success:function (data) {
						var a = data;
						var html = '';
						for(var i=0;i<a.length;i++ ) {
							
							html += '<option value ="'+a[i].area_name+'" data-id="'+a[i].area_id+'">'+a[i].area_name+'</option>';
						}
						
						 $("#cobb").html(html);						
					}
				});
				var parent =$(this).val();
				$.ajax({
					url:url,
					data:{id:code,parent:parent},
					type:'post',
					//dataType:'json',
					success:function (data) {
						var a = data;
						var html2 = '';
						for(var i=0;i<data.length;i++ ) {
							
							html2 += '<option value ="'+data[i].area_name+'" data-id="'+data[i].area_id+'">'+data[i].area_name+'</option>';
						}
						//alert(html);
						 $("#cocc").html(html2);						
					}
				});					
			}
			

        });
		
        $('#cobb').change(function(){
			var name = $(this).val();
            var code = $(this).find("option[value='"+name+"']").attr("data-id");
			//alert(code);
			var url = '{:U("/shop/code_chage")}';
			if (code) {			
				$.ajax({
					url:url,
					data:{id:code},
					type:'post',
					//dataType:'json',
					success:function (data) {
						var a = data;
						var html2 = '';
						for(var i=0;i<data.length;i++ ) {
							
							html2 += '<option value ="'+data[i].area_name+'" data-id="'+data[i].area_id+'">'+data[i].area_name+'</option>';
						}
						
						 $("#cocc").html(html2);						
					}
				});					
			}
        });		
    </script>
	<script type="text/javascript">
	$(function(){

		$('input').change(function(){
			$("#addresshash").val(_getRandomString(32));

		});
		$('select').change(function(){
			$("#addresshash").val(_getRandomString(32));
		});
	});
	

	// 获取长度为len的随机字符串  
	function _getRandomString(len) {  
		len = len || 32;  
		var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; // 默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1  
		var maxPos = $chars.length;  
		var pwd = '';  
		for (i = 0; i < len; i++) {  
			pwd += $chars.charAt(Math.floor(Math.random() * maxPos));  
		}  
		return pwd;  
	} 
  </script>
	</block>